package com.CuiChangHe.studentmanager.controller;

import com.CuiChangHe.studentmanager.dao.StudentLeaveInfoDao;
import com.CuiChangHe.studentmanager.entity.studentleave.StudentLeaveInfoReturnMsg;
import com.CuiChangHe.studentmanager.service.studentleaveinfo.StudentLeaveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :请销假Controller
 * @Author :崔昌赫
 * @Date : 2021/11/19
 */
@RestController
@Slf4j
public class StudentLeaveInfoController {

    private StudentLeaveService service;

    @Autowired
    public void setService(StudentLeaveService service) {
        this.service = service;
    }

    @GetMapping("/student/leave/get/all")
    StudentLeaveInfoReturnMsg getAllStudentLeaveInfo(){
        return service.getAllLeaveInfo();
    }

    @GetMapping("/student/leave/get/checked")
    StudentLeaveInfoReturnMsg getAllNon_CheckedLeaveInfo(){
        return service.getAllNon_CheckedLeaveInfo();
    }

    @GetMapping("/student/leave/get/report")
    StudentLeaveInfoReturnMsg getAllNon_ReportLeaveInfo(){
        return service.getAllNon_ReportLeaveInfo();
    }

    @GetMapping("/student/leave/get/finish")
    StudentLeaveInfoReturnMsg getAllFinishLeaveInfo(){
        return service.getAllFinishInfo();
    }

    @PostMapping("/student/leave/add")
    StudentLeaveInfoReturnMsg addNewLeaveInfo(@RequestBody StudentLeaveInfoDao data){
        log.debug(String.valueOf(data));
        return service.addNewLeaveInfo(data);
    }

    @PutMapping("/student/leave/check/agree/{identifier}")
    StudentLeaveInfoReturnMsg checkedRefuseLeaveInfo(@PathVariable String identifier){
        return service.CheckAgree(identifier);
    }

    @PutMapping("/student/leave/check/refuse/{identifier}")
    StudentLeaveInfoReturnMsg checkedAgreeLeaveInfo(@PathVariable String identifier){
        return service.CheckRefuse(identifier);
    }

    @PutMapping("/student/leave/report/{identifier}")
    StudentLeaveInfoReturnMsg reportLeaveInfo(@PathVariable String identifier){
        return service.Report(identifier);
    }

}
